//
//  UIBarButtonItem+Extension.swift
//  Sina
//
//  Created by YYY on 2017/8/14.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

//import Foundation

//import UIKit

extension UIBarButtonItem
{
    /*
     遍历构造函数
     格式： convenience init(形参名：类型，形参名：类型)
     {
     /*
     设置属性
     */
     self.init()
     }
     */
    
    convenience init(size: CGSize,titleStr: String,fontSize: CGFloat,target: AnyObject?,selector: Selector,isBack: Bool)
    {
        let leftBtn = UIButton(frame: CGRect(x: 0, y: 0, width: size.width, height: size.height))
        if isBack
        {
            leftBtn.setImage(UIImage(named: "navigationbar_back_withtext"), for: .normal)
            leftBtn.setImage(UIImage(named: "navigationbar_back_withtext_highlighted"), for: .highlighted)
            //leftBtn.sizeToFit()
        }
        leftBtn.setTitle(titleStr, for: .normal)
        leftBtn.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        leftBtn.setTitleColor(UIColor.darkGray, for: .normal)
        leftBtn.setTitleColor(UIColor.orange, for: .highlighted)
        leftBtn.addTarget(target, action: selector, for: .touchUpInside)
        self.init(customView: leftBtn)
    }

}
